import React from 'react'
import { Button } from 'antd'
import { SearchOutlined, ReloadOutlined, PlusOutlined, DeleteOutlined } from '@ant-design/icons';
import './index.less'

export default function TableSearch(props: any) {
    let {
        isExtra,
        isSearch = true,
        ExtraComponent,
        isDelete = true,
        children,
    } = props;
    return (
        <div className='table_search_frame'>
            {
                isSearch && (
                    <div className='search_header'>
                        {children}
                        <Button className='btn search_btn' type="primary" icon={<SearchOutlined />} onClick={() => props.search()}>搜索</Button>
                        <Button className='btn' icon={<ReloadOutlined />} onClick={() => props.reset()}>重置</Button>
                    </div>
                )
            }
            {
                isExtra && <div className='search_footer'>
                    {
                        ExtraComponent ? ExtraComponent : (
                            <>
                                <Button className='btn' type="primary" icon={<PlusOutlined />} onClick={() => props.add()}>新增</Button>
                                <Button className='btn' type="primary" danger icon={<DeleteOutlined />} onClick={() => props.delete()} disabled={isDelete}>删除</Button>
                            </>
                        )
                    }
                </div>
            }
        </div>
    )
}
